[#include "/WEB-INF/pages/common/taglibs.ftl"]
[@c.url var="backUrl" value="/manage/Config_list.action" scope="page"][/@c.url]
[#macro _script]
	<script type="text/javascript" src="[@c.url value='/js/plugins/jquery.alerts.js'/]"></script>
	<script type="text/javascript">
		var base = (function(){
			// 事件绑定
			function _addEventListeners() {
				// 维护
				$('a[act=edit]').unbind('click').click(function(){
					var	id = $(this).parent().attr('tval');
					//$.get(url, {'id':id, 'ajax':'true'}, function(data) {
					//	$('.config_edit').html(data);
					//	base.init();
					//})
					window.location	= "[@c.url value='/manage/Config_edit.action' scope="page"][@c.param name="backurl" value="${backUrl}"/][@c.param name="id" value=""/][/@c.url]" + id;
				})
				
				// 删除
				$('a[act=delete]').unbind('click').click(function(){
						var	id = $(this).parent().attr('tval');
						var title = $('#delete-confirm').attr('title');
						var content = $('#delete-confirm').html();
						jConfirm(content, title, function(r) {
							if (r) {
								[@c.url	var="deleteUrl" value='/manage/Config_delete.action' scope="page"]
									[@c.param name="backurl" value="${backUrl}"/]
									[@c.param name="id" value=""/]
								[/@c.url]
								window.location	= "${deleteUrl}" + id;
							}
						});
					return false;
				})
			};
			function _addDateTableRender() {
				$('#dyntable').unbind().bind('sort', function (){ _addEventListeners(); })
					.dataTable( {
						"sPaginationType": "full_numbers",
					 	"oLanguage": {
						 	"sSearch": "检索：",
				            "sLengthMenu": "每页显示 _MENU_ 条记录",
				            "sZeroRecords": "未找到数据.",
				            "sInfo": "显示 _START_-_END_ 条  【共 _TOTAL_ 条】",
				            "sInfoEmpty": "显示 0-0 条 共 0 条",
				            "sInfoFiltered": "(filtered from _MAX_ total records)",
				            "oPaginate": {
				            	"sFirst": "首页",	            	
				            	"sPrevious": "上一页",
				            	"sNext": "下一页",
				            	"sLast": "末页"
				            }
				        }
					});
				//$("#dyntable_length").prepend('<button title="table1" class="deletebutton radius3" onclick="javascript:window.location=[@c.url value='/manage/Config_create.action' scope="page"/]">新建配置</button>&nbsp;&nbsp;');
				//增加新建配置按钮
				$("#dyntable_length").prepend('<a href="[@c.url value='/manage/Config_create.action' scope="page"/]" class="radius3"><span>新建配置</span></a>&nbsp;&nbsp;');	
			}
			return {
                config: {
                	url : null,
                    theme: null
                },
                init: function () {
                    _addEventListeners();
                    _addDateTableRender();
                }
			}
		}());
		
		$(function(){
			var link = "[@c.url value='/manage/Config_list.action?currentPage=${currentPage}' /]";
			base.config.theme = getTheme();
			base.config.url = link;
            //Initializing the form
			base.init();
		})
	</script>
[/#macro]

[#macro _content]
	[@demo.tableDisplayer id="id" renderTo="${renderTo}" ajaxPage="true"  property="siteConfigList" pagesize=4 page="/manage/Config_list.action" name="FreemarkerTable" config="/WEB-INF/component/table/template-stdtable-autopage.ftl" bundle="messageSource"]
		[@demo.column name="id" property="id" title="ID" headerClass="" columnClass="span-tiny"/]
		[@demo.column name="path" property="title" title="标题" columnClass=""/]
		[@demo.column name="name" property="name" title="名称" columnClass="span3"/]
		[@demo.column name="type" property="type" title="类型" format='{"INLAY":"内置类型", "SITE":"自定义类型"}'  columnClass="span1-1"/]
		[@demo.column name="value" property="value" title="值" columnClass="span1"/]
		[@demo.column name="enabled" property="enabled" format="可用:禁用" title="启用状态" columnClass="span1"/]
		[@demo.column name="operate" property="id" title="操作" columnClass="span1" innerHtml="\la href='javascript:void(0);' act='edit' \g编辑\l/a\g&nbsp;|&nbsp;\la href='javascript:void(0);' act='delete' \g删除\l/a\g" headerClass="batch"/]
	[/@demo.tableDisplayer]
	[#-- 系统内置配置和站点配置合并展示
	[@demo.tableDisplayer id="inlayConfig" renderTo="${renderTo}" ajaxPage="true"  property="inlayConfigList" pagesize=4 page="/manage/Config_list.action" name="FreemarkerTable" config="/WEB-INF/component/table/template-stdtable-autopage.ftl" bundle="messageSource"]
		[@demo.column name="id" property="id" title="ID" headerClass="" columnClass=""/]
		[@demo.column name="path" property="title" title="标题" columnClass=""/]
		[@demo.column name="name" property="name" title="名称" columnClass=""/]
		[@demo.column name="type" property="type" title="类型" columnClass=""/]
		[@demo.column name="enabled" property="enabled" format="可用:禁用" title="启用状态" /]
		[@demo.column name="operate" property="id" title="操作" innerHtml="\la href='javascript:void(0);' act='edit' \g编辑\l/a\g&nbsp;|&nbsp;\la href='javascript:void(0);' act='delete' \g删除\l/a\g" headerClass="batch"/]
	[/@demo.tableDisplayer]
	--]
	<div id="delete-confirm" style="display:none" title="配置删除">
		<p>配置删除后将无法恢复.您确认删除吗？</p>
	</div>
[/#macro]

[#if piece==true]
		[@_script /]
		<!--设置提交行为-->
		[#assign act="save" /]
		<!--设置table渲染到指定ID节点-->
		[@_content /]
[#else]
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Insert title here</title>
		<meta name="menu" content="AdminMenu"/>
		<meta name="heading" content="heading"/>
		[@_script /]
	</head>
	<body id="body">
		<div class="contenttitle radiusbottom0">
			<h2 class="table"><span>配置列表</span></h2>
		</div><!--contenttitle-->
		[@_content /]
    	[#--[@s.action name="Config_create" executeResult="true" namespace="/manage"]
    		[@s.param name="ajax" value="true" /]
    		[@s.param name="piece" value="true"/]
    	[/@s.action]--]
	</body>
	</html>
[/#if]